<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'app',
  data(){
    return{
      ws:null
    }
  },
  methods:{
    initWebSocket(){
      let url = "ws://"+window.location.host+"/msmis/websocket/socketServer.do";
      if('WebSocket' in window)
        this.ws = new WebSocket(url);
      else
        this.ws = new MozWebSocket(url);
      this.ws.onopen = this.wsopen;
      this.ws.onmessage = this.wsmessage;
      this.ws.onclose = this.wsclose;
    },
    wsopen(e){
    },
    wsmessage(e){
      const h = this.$createElement;
      let message = e.data
      this.$notify.info({
        title: "消息提示",
        message:h('i',{style:"color:blue"},message),
        offset: 800,
        duration: 0
      });
    },
    wsclose(e){
    }
  },
  updated(){
    if(this.ws==null&&this.$store.getters.user!=null)
      this.initWebSocket();
  }
}
</script>

<style lang="scss">
  @import '~normalize.css/normalize.css';// normalize.css 样式格式化
  @import './styles/index.scss'; // 全局自定义的css样式
</style>
